#ifndef SHOGIERROR_H_INCLUDED
#define SHOGIERROR_H_INCLUDED

#include <QString>

struct ShogiErrorText 
{
	int		errorCode;
	const char*	errorString;
};	

enum ShogiErrorCodes
{
	OK		=	0,
	ERROR_PARSING_COMMAND,
	END_OF_ERRORS_MARKER
};

// Order is important here, same order as ShogiErrorCodes
static const ShogiErrorText ERRORS[END_OF_ERRORS_MARKER] = 
{
	{ OK							, ""	},
	{ ERROR_PARSING_COMMAND			, "Could not parse command." },
};


class ShogiError
{
public:
	ShogiError() : m_nErrorCode(0),m_strError("") {}
	ShogiError(int errorCode) : m_nErrorCode(errorCode)
	{
		m_strError = ERRORS[errorCode].errorString;
	}

	int getErrorCode() const { return m_nErrorCode; }
	QString getErrorString() const { return m_strError;	}

	void setError(int errorCode) { m_nErrorCode = errorCode; m_strError = ERRORS[errorCode].errorString;}
	void reset() { m_nErrorCode = 0; m_strError = ""; }
	
private:
	int m_nErrorCode;
	QString m_strError;
};

#endif // SHOGIERROR_H_INCLUDED

